﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpGen.Compiler
{
    /// <summary>
    /// Stellt ein Enum-Element dar
    /// </summary>
    [Serializable]
    public class OpGenEnum : OpGenElement
    {
        /// <summary>
        /// Erstellt eine neue Instanz der EnumElement-Klasse
        /// </summary>
        /// <param name="Element"></param>
        public OpGenEnum(OpGenNamespace Element) : base(Element, ElementTypeEnum.Enum)
        {

        }

        /// <summary>
        /// Gibt an ob ein Schlüssel bereits enthalten ist
        /// </summary>
        /// <param name="Keyname"></param>
        /// <returns></returns>
        public bool Contains(string Keyname)
        {
            return ChildElements.Contains(Keyname);
        }

        /// <summary>
        /// Liefert den Wert des Schlüssels
        /// </summary>
        /// <param name="Keyname"></param>
        /// <returns></returns>
        public int GetValue(string Keyname)
        {
            return ((OpGenEnumItem)ChildElements[Keyname]).Value;
        }

        /// <summary>
        /// Gibt an ob die Enumeration das Flag Attribute erhalten soll
        /// </summary>
        public bool IsFlag { get; set; }

        /// <summary>
        ///  Liefert die Textbezeichnung des Elements
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return base.ToString() + (IsFlag ? "\n Flag Attribute" : "");
        }
    }
}
